<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="${pageContext.request.contextPath}/css/sys.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/Calendar.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/getXmlHttp.js"></script>
<script type="text/javascript">
	function showPost(select){
		//get department id
		var depId = select.value;
		//connect address
		var address = "${pageContext.request.contextPath}/postAction_showPostByDepartment.action?post.crmDepartment.depId="+depId;
		//get xmlHttp object
		var xmlHttp = getXmlHttpObject();
		//set callback function
		xmlHttp.onreadystatechange = function(){
			//request success
			if(xmlHttp.readyState==4&&xmlHttp.status==200){
				var textData = xmlHttp.responseText;
				var jsonData = eval("("+textData+")");
				var postSelect = document.getElementById("postSelect");
				postSelect.innerHTML = "<option value=''>----请--选--择----</option>";
					
					//3.2 遍历
					for(var i = 0 ; i < jsonData.length ; i++){
						var postObj = jsonData[i];
						// 获得职务id
						var postId = postObj.postId;
						// 获得职务名称
						var postName = postObj.postName;
						//3.3 将数显示到select标签
						postSelect.innerHTML += "<option value='"+postId+"'>"+postName+"</option>";
					}
			}
		};
		xmlHttp.open("GET", address);
		xmlHttp.send(null);
	}
</script>
</head>

<body class="emp_body">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
  <tr>
    <td class="topg"></td>
  </tr>
</table>

<table border="0" cellspacing="0" cellpadding="0"  class="wukuang"width="100%">
  <tr>
    <td width="1%"><img src="${pageContext.request.contextPath}/images/tleft.gif"/></td>
    <td width="44%" align="left">[员工管理]</td>
   
    <td width="52%"align="right">
    	<!-- 提交表单 -->
       <a href="javascript:void(0)" onclick="document.forms[0].submit()">
       	<img src="${pageContext.request.contextPath}/images/button/save.gif" />
       </a>
       <!-- 执行js，进行返回 -->
       <a href="javascript:void(0)" onclick="window.history.go(-1)"><img src="${pageContext.request.contextPath}/images/button/tuihui.gif" /></a>
      
    </td>
    <td width="3%" align="right"><img src="${pageContext.request.contextPath}/images/tright.gif"/></td>
  </tr>
</table>

<form action="${pageContext.request.contextPath}/staffAction_addStaff.action" method="post">
	<table width="88%" border="0" class="emp_table" style="width:80%;">
	 <tr>
	    <td>登录名：</td>
	    <td><input type="text" name="staff.loginName" value="" /> </td>
	    <td>密码：</td>
	    <td><input type="password" name="staff.loginPwd" /> </td>
	  </tr>
	 <tr>
	    <td>姓名：</td>
	    <td><input type="text" name="staff.staffName" value="" id="staffAction_add_staffName"/> </td>
	    <td>性别：</td>
	    <td><input type="radio" name="staff.gender"  value="男"/>男
	    	<input type="radio" name="staff.gender"  value="女"/>女
		</td>
	  </tr>
	 <tr>
	    <td width="10%">所属部门：</td>
	    <td width="20%">
	    	<s:select name="staff.crmPost.crmDepartment.depId" list="%{#allDepartments}" listKey="depId" listValue="depName"
	    		headerKey="" headerValue="----请--选--择----" onchange="showPost(this)"/>
	    	

	    </td>
	    <td width="8%">职务：</td>
	    <td width="62%">
	    	<s:select name="staff.crmPost.postId" id="postSelect" list="staff.crmPost != null ? staff.crmPost.crmDepartment.crmPosts : {}"
	    		listKey="postId" listValue="postName" headerKey="" headerValue="----请--选--择----"></s:select>
	    	
	    </td>
	  </tr>
	   <tr>
	    <td width="10%">入职时间：</td>
	    <td width="20%">
	    	<input type="text" name="staff.onDutyDate" value="" readonly="readonly"  onfocus="c.showMoreDay=true; c.show(this);" />
	    </td>
	    <td width="8%"></td>
	    <td width="62%"></td>
	  </tr>
	</table>
</form>
<hr/>
<s:debug></s:debug>
</body>
</html>
